package com.gw.mvc.unit;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.gw.mvc.form.ActionForm;

public class FullBean {
	
	public static ActionForm full(HttpServletRequest request , 
			String className ){
		ActionForm form = null;
		try{
			Class clazz = Class.forName( className );
			form = (ActionForm)clazz.newInstance();
			Field[] fields = clazz.getDeclaredFields();
			for( Field field : fields ){
				field.setAccessible( true );
				field.set(form, request.getParameter( field.getName() ));
				field.setAccessible( false );
			}
		}catch(Exception ex){
			ex.printStackTrace();
			System.out.println( "" );
		}
		return form;
	}
}
